#include "stdio.h"
#include "math.h"
#define Maxx 400
#define Maxy 200

double distance(double x,double y,double k,double *meetx,double *meety)
{
	double dis,bk,b,tox,toy;
	
	if (k==0)
	{
		dis=Maxy-y;
		tox=x;toy=Maxy;
	}
	else if (k==90)
	{
		dis=Maxx-x;
		tox=Maxx;toy=y;
	}
	else if (k==180)
	{
		dis=y-0;
		tox=x;toy=0;
	}
	else if (k==270)
	{
		dis=x-0;
		tox=0;toy=y;
	}
	else
	{
		bk=k;
		k=-k+90;
		k=(k/180*3.14159265358979);
		k=tan(k);
		b=y-k*x;
		if (bk>0&&bk<90)
		{
			toy=Maxx*k+b;
			if (toy<=Maxy) tox=Maxx;
			else
			{
				tox=(Maxy-b)/k;
				toy=Maxy;
			}			
		}
		else if (bk>90&&bk<180)
		{
			toy=Maxx*k+b;
			if (toy>=0) tox=Maxx;
			else
			{
				tox=(0-b)/k;
				toy=0;
			}
		}
		else if (bk>180&&bk<270)
		{
			toy=0*k+b;
			if (toy>=0) tox=0;
			else
			{
				tox=(0-b)/k;
				toy=0;
			}
		}
		else 
		{
			toy=0*k+b;
			if (toy<=Maxy) tox=0;
			else
			{
				tox=(Maxy-b)/k;
				toy=Maxy;
			}
		}	
		dis=sqrt((x-tox)*(x-tox)+(y-toy)*(y-toy));
	}
	*meetx=tox;
	*meety=toy;

	return dis;
	
}


void zhouxy(double *x,double *y,double k,double d)
{

	if (k==0)
	{
		*y+=d;		
	}
	else if (k==90)
	{
		*x+=d;
	}
	else if (k==180)
	{
		*y-=d;
	}
	else if (k==270)
	{
		*x-=d;
	}
	else
	{	
		k=-k+90;
		k=(k/180*3.14159265358979);
		*y+=d*sin(k);
		*x+=d*cos(k);		
	}

}



int main()
{
	int i,n,out,casen;

	double begin,end,speed,order,x,y,tot,dis,walk,meetx,meety,time,maxdis,temp; 
	
	
//	printf("%lf\n",sqrt(198*198+(200-18.46)*(200-18.46)));

//	printf("%lf\n",distance(300,100,45,&meetx,&meety));
//	printf("%lf %lf\n",meetx,meety);

	casen=0;
	scanf("%d",&n);
	while (n)
	{
		casen++;
		x=200; /* max x is 400 ;max y is 200 */
		y=0;
		maxdis=0;
		tot=0;
		out=0;
		for (i=1;i<=n;i++)
		{
			scanf("%lf%lf%lf%lf",&begin,&end,&speed,&order);
			walk=(end-begin)*speed;			
			tot+=walk;
			if (!out)
			{
				dis=distance(x,y,order,&meetx,&meety);				
				
				if ((walk-dis)>=0.00000001)
				{
					out=1;
					time=begin+dis/speed;					
					continue;
				}
				zhouxy(&x,&y,order,walk);
				temp=sqrt( (x-200)*(x-200)+(y*y) );
				if (maxdis<temp) maxdis=temp;				
			//	printf("walk is :%lf, dis = %lf \n",walk,dis);
			//	printf("now x y is (%lf,%lf)\n\n",x,y);
			}
		}		
		printf("Case Number %d\n",casen);
		if (!out) 
		{
			printf("No departure from restricted area\n");
			printf("Maximum distance patient traveled from door was %.1lf feet\n",maxdis);
		}
		else
			printf("Left restricted area at point (%.1lf,%.1lf) and time %.1lf sec.\n",meetx,meety,time);

		printf("Total distance traveled was %.1lf feet\n",tot);
		printf("***************************************\n");

		scanf("%d",&n);
	}

	return 0;
}